package edu.unindra.elearning;

import java.sql.*;
import java.sql.DriverManager;

public class DB {

	// Untuk koneksi ke MySQL
	private String userid = "root";
	private String password = "5678";

	String url = "jdbc:mysql://localhost:3306/elearning";

	public Connection con;

	// constructor
	public DB() {
		getConnection();
	}

	public Connection getConnection() {
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (java.lang.ClassNotFoundException e) {
			System.err.print("Koneksi dengan Datagase gagal: ");
			System.err.println(e.getException());
		}

		try {
			con = DriverManager.getConnection(url, userid, password);
			System.out.print("Nyambung");

		} catch (SQLException e) {
			System.err.println("ID dan Password Anda gagal " + e.getMessage());
		}

		return con;
	}

	public static void main(String[] args) {
		new DB();
	}
}
